import math
#剩余牌计算1.0
def calculate_card_probability():
    """计算至少抽到一张目标牌的概率"""
    try:
        # 输入参数
        total_cards = int(input("请输入牌堆剩余总牌数："))
        target_cards = int(input("请输入目标牌的数量："))
        draw_num = int(input("请输入要抽取的牌数："))

        # 输入验证
        if total_cards <= 0 or target_cards < 0 or draw_num <= 0:
            raise ValueError("输入必须为正整数且目标牌数量非负")
        if target_cards > total_cards:
            raise ValueError("目标牌数量不能超过总牌数")
        if draw_num > total_cards:
            raise ValueError("抽牌数不能超过剩余牌数")

        # 计算组合数
        fail_comb = math.comb(total_cards - target_cards, draw_num)
        total_comb = math.comb(total_cards, draw_num)

        # 计算概率并输出
        probability = 1 - fail_comb / total_comb
        print(f"\n抽卡概率计算结果：{probability:.4%}")

    except ValueError as e:
        print(f"输入错误：{e}")

# 执行计算
calculate_card_probability()
